package com.ramble.buildingservice.domain.household.service;

import com.ramble.buildingservice.api.UserServiceApiClient;
import com.ramble.buildingservice.api.dto.UserDto;
import com.ramble.buildingservice.domain.household.dto.HouseholdDetailDto;
import com.ramble.buildingservice.domain.household.dto.HouseholdDto;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class HouseholdServiceImpl implements HouseholdService {


    @Autowired
    private UserServiceApiClient userServiceApiClient;

    @Override
    public HouseholdDetailDto getHouseholdDetail(Long id) {
        HouseholdDetailDto householdDetailDto = new HouseholdDetailDto();
        HouseholdDto householdDto = this.getHousehold(id);
        BeanUtils.copyProperties(householdDto, householdDetailDto);
        UserDto userDto = userServiceApiClient.getUser(householdDto.getBelongUserId());
        householdDetailDto.setUser(userDto);
        return householdDetailDto;
    }

    @Override
    public HouseholdDto getHousehold(Long id) {
        HouseholdDto householdDto = new HouseholdDto().setId(id).setBelongUserId(88L).setName("科技大厦");
        return householdDto;
    }
}
